import { Component, OnInit, HostListener, Input, ElementRef, Renderer2 } from '@angular/core';
import { MousedownListenerDirective } from '../shared/directive/mousedown-listener.directive';

@Component({
  selector: 'app-time',
  templateUrl: './time.component.html',
  styleUrls: ['./time.component.css']
})
export class TimeComponent implements OnInit {

  @Input()
  time: string;

  @Input()
  isLeftKeyDown: boolean;

  isSelect: boolean;
  myClass = {};
  constructor(private el: ElementRef, private renderer: Renderer2) {
    this.isSelect = false;
  }
  ngOnInit() {
    console.log('on init start....');
  }

  // onLeftkeydown(): void {
  //   this.isLeftKeyDown = true;
  // }

  // onLeftkeyup(): void {
  //   console.log('key up start....');
  //   this.isLeftKeyDown = false;
  // }

  @HostListener('mouseover', ['$event'])
  mouseover(event: MouseEvent) {
    console.log('mouse over');
    if (this.isLeftKeyDown) {
      this.isSelect = true;
    } else {
      this.isSelect = false;
    }
  }

  toggleSelected() {
    if (this.isSelect) {
      this.isSelect = false;
    } else {
      this.isSelect = true;
    }
  }

}
